package com.tyut.springboottest.controller;

import com.tyut.springboottest.domin.Student;
import com.tyut.springboottest.service.StudentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/students")
public class StudentController {
    // 注入 studentService 实例
    private final StudentService studentService;

    // 构造器注入
    public StudentController(StudentService studentService) {
        this.studentService = studentService;
    }

    @GetMapping("/getStudent")
    public Student getStudent() {
        // 调用 studentService 实例中的 getStudent 方法并返回结果
        return studentService.getStudent();
    }
}